﻿﻿
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
	String basePath = "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="/">
    <!-- 下拉框 -->
    <link rel="stylesheet" href="static/ace/css/chosen.css"/>
    <!-- jsp文件头和头部 -->
    <%@ include file="../index/top.jsp" %>
    <!-- 日期框 -->
    <link rel="stylesheet" href="static/ace/css/datepicker.css"/>
    <link rel="stylesheet" href="static/styles/base.css"/>
</head>
<body class="no-skin">

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">

                        <!-- 检索  -->
                        <form action="reconciliation/list.do" method="post" name="goodsForm" id="goodsForm">
                            <table style="margin-top:5px;">
                                <tr>
                                	<td class="center" style="padding-left:5px;">
                                        	支付方式:
                                    </td>
                                     <td style="vertical-align:top;padding-left:5px;">
                                        <select class="chosen-select form-control" name="pay_mode" id="pay_mode"
                                                data-placeholder="支付方式" style="vertical-align:top;width: 100px;">
                                            <option value="">全部</option>
                                            <option value="wechat" <c:if test="${pd.pay_mode=='wechat'}">selected</c:if>>微信
                                            </option>
                                            <option value="alipay" <c:if test="${pd.pay_mode=='alipay'}">selected</c:if>>支付宝
                                            </option>
                                        </select>
                                    </td>
                                    <td class="zdyTime" style="padding-left:5px;"> <input class="span10 date-picker" name="LongTerm" id="LongTerm" value="${pd.LongTerm}" type="text" style="width:88px;" placeholder="选择月份"  title="选择月份"/></td>
                                    <td class="center" style="padding-left:5px;"> 自定义时间 </td>
                                    <td class="input-daterange"> 
                                    	<div class="dib vm pl5"><input class="span10 date-picker" name="startTime" id="startTime" value="${pd.startTime}" type="text"  style="width:88px;" placeholder="选择日期" title="选择日期"/></div>
                                    	<div class="dib vm pl5">至</div>
                                    	<div class="dib vm pl5"><input class="span10 date-picker" name="endTime" id="endTime" value="${pd.endTime}" type="text" style="width:88px;" placeholder="选择日期" title="选择日期"/></div>
                                    </td>
                                   <%-- <td class="center" style="padding-left:5px;">
                                        	对账状态:
                                    </td>
                                      <td style="vertical-align:top;padding-left:5px;">
                                        <select class="chosen-select form-control" name="reconciliation_state" id="reconciliation_state"
                                                data-placeholder="对账状态" style="vertical-align:top;width: 100px;">
                                            <option value="">全部</option>
                                            <option value="00" <c:if test="${pd.reconciliation_state=='00'}">selected</c:if>>未对账
                                            </option>
                                            <option value="01" <c:if test="${pd.reconciliation_state=='01'}">selected</c:if>>已对账
                                            </option>
                                        </select>
                                    </td> --%>
                                    <c:if test="${QX.cha == 1 }">
                                        <td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs"
                                                                                            onclick="searchs();"
                                                                                            title="检索"><i
                                                id="nav-search-icon"
                                                class="ace-icon fa fa-search bigger-110 nav-search-icon blue"></i></a>
                                        </td>
                                    </c:if>
                                    <c:if test="${QX.toExcel == 1 }">
                                        <td style="vertical-align:top;padding-left:2px;"><a class="btn btn-light btn-xs"
                                                                                            onclick="toExcel();"
                                                                                            title="导出到EXCEL"><i
                                                id="nav-search-icon"
                                                class="ace-icon fa fa-download bigger-110 nav-search-icon blue"></i></a>
                                        </td>
                                    </c:if>
                                </tr>
                            </table>
                            <!-- 检索  -->
							<div style="padding-top:30px;">
								<span>收入笔数：${numPen } (笔)</span>
								<span>收入金额：${sumPrice } (元)</span>
							</div>
                            <table id="simple-table" class="table table-striped table-bordered table-hover"
                                   style="margin-top:5px;">
                                <thead>
                                <tr>
                                    <th class="center" style="width:50px;">序号</th>
                                    <th class="center">交易编码</th>
                                    <th class="center">第三方交易编码</th>
                                    <th class="center">用户手机号</th>
                                    <th class="center">支付方式</th>
                                    <th class="center">支付金额</th>
                                    <th class="center">商品</th>
                                    <th class="center">支付时间</th>
                                   <!--  <th class="center">对账状态</th> -->
                                </tr>
                                </thead>

                                <tbody id="goodlist">

                                <!-- 开始循环 -->
                                <c:choose>
                                    <c:when test="${not empty reconciliationList}">
                                        <c:if test="${QX.cha == 1 }">
                                            <c:forEach items="${reconciliationList}" var="recon" varStatus="vs">
                                                <tr>
                                                    <td class='center' style="width: 30px;">${vs.index+1}</td>
                                                    <td class="center">${recon.transaction_code }</td>
                                                    <td class="center">${recon.tradeNo }</td>
                                                    <td class="center">${recon.phone }</td>
                                                    <td class="center"><c:if test="${recon.pay_mode!=null}"><c:if
                                                            test="${recon.pay_mode=='wechat'}">微信</c:if><c:if
                                                            test="${recon.pay_mode=='alipay'}">支付宝</c:if></c:if><c:if
                                                            test="${recon.pay_mode==null}">未选择</c:if></td>
                                                    <td class="center">${recon.price }</td>
                                                    <td class="center">${recon.remark }</td>
                                                    <td class="center">${recon.finish_time }</td> 
                                                   <%--  <td class="center">
                                                    <c:if test="${recon.reconciliation_state!=null}"><c:if
                                                            test="${recon.reconciliation_state=='00'}">未对账</c:if><c:if
                                                            test="${recon.reconciliation_state=='01'}">已对账</c:if></c:if></td> --%>
                                                    
                                                </tr>
                                            </c:forEach>
                                        </c:if>
                                        <c:if test="${QX.cha == 0 }">
                                            <tr>
                                                <td colspan="13" class="center">您无权查看</td>
                                            </tr>
                                        </c:if>
                                    </c:when>
                                    <c:otherwise>
                                        <tr class="main_info">
                                            <td colspan="13" class="center">没有相关数据</td>
                                        </tr>
                                    </c:otherwise>
                                </c:choose>
                                </tbody>
                            </table>
                            <div class="page-header position-relative">
                                <table style="width:100%;">
                                    <tr>
                                        <td style="vertical-align:top;">
                                            <div class="pagination"
                                                 style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </form>

                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>
    </div>
    <!-- /.main-content -->

    <!-- 返回顶部 -->
    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

</div>
<!-- /.main-container -->

<!-- basic scripts -->
<!-- 页面底部js¨ -->
<%@ include file="../index/foot.jsp" %>
<!-- 删除时确认窗口 -->
<script src="static/ace/js/bootbox.js"></script>
<!-- ace scripts -->
<script src="static/ace/js/ace/ace.js"></script>
<!-- 日期框 -->
<script src="static/ace/js/date-time/bootstrap-datepicker.js"></script>
<!-- 下拉框 -->
<script src="static/ace/js/chosen.jquery.js"></script>
<!--提示框-->
<script type="text/javascript" src="static/js/jquery.tips.js"></script>
</body>

<script type="text/javascript">
    $(top.hangge());
    
    
    var spanDateFormat = 'yyyy-mm-dd';
    $('.input-daterange').datepicker({
    	  autoclose: true,
    	  format: "yyyy-mm-dd",
    	  maxViewMode: 0,
    	});
    
    $(".zdyTime input").datepicker({
   	 format: "yyyy-mm",
   	 startView: 1,
   	 minViewMode: 1,
   	 maxViewMode: 2,
   	 language: "zh-CN",
   	 autoclose: true
	});

    //检索
    function searchs() {
    	var startTime = $("#startTime").val();//开始时间
    	var endTime = $("#endTime").val();//结束时间
    	if(startTime!="" && endTime!=""){
    		$("#LongTerm").val('');
    	}
        top.jzts();
        $("#goodsForm").submit();
    }

    //排序编辑
    $(function () {
        $('.date-picker').datepicker({autoclose: true, todayHighlight: true});
        var tdObj = "";
        var oldText = "";
        var inputObj = "";
        var newText = "";
        var id = "";
        if ('${QX.edit}' == 1) {
            //给这些单元格注册鼠标点击事件
            $("#goodlist tr").each(function () {
                $(this).children('#seq').click(function () {
                    id = $(this).next().text();//获取下一个同级元素，即id
                    //找到当前鼠标单击的td
                    tdObj = $(this);
                    //保存原来的文本
                    oldText = $(this).text();
                    //创建一个文本框
                    inputObj = $("<input type='text' value='" + oldText + "'/>");
                    //去掉文本框的边框
                    inputObj.css("border-width", 0);
                    inputObj.click(function () {
                        return false;
                    });
                    //使文本框的宽度和td的宽度相同
                    inputObj.width(tdObj.width());
                    inputObj.height(tdObj.height());
                    //去掉文本框的外边距
                    inputObj.css("margin", 0);
                    inputObj.css("padding", 0);
                    inputObj.css("text-align", "center");
                    inputObj.css("font-size", "16px");
                    inputObj.css("background-color", tdObj.css("background-color"));
                    //把文本框放到td中
                    tdObj.html(inputObj);
                    //文本框失去焦点的时候变为文本
                    inputObj.blur(function () {
                        newText = $(this).val();
                        if (!isInt(newText) || newText.length > 8) {
                            alert("只能输入最多8位整数");
                            tdObj.html(oldText);
                        } else {
                            $.get("goods/updateSeq.do?id=" + id + '&seq=' + newText, function (data, status) {
                                if (data == "success") {
                                    tdObj.html(newText);
                                }
                                else {
                                    tdObj.html(oldText);
                                }
                            });
                        }

                    });
                });
            });
        }
    });

    //检查是否为正整数
    function isInt(a) {
        var reg = /^\d+$/;
        return reg.test(a);
    }

    //复选框全选控制
    var active_class = 'active';
    $('#simple-table > thead > tr > th input[type=checkbox]').eq(0).on('click', function () {
        var th_checked = this.checked;//checkbox inside "TH" table header
        $(this).closest('table').find('tbody > tr').each(function () {
            var row = this;
            if (th_checked) $(row).addClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', true);
            else $(row).removeClass(active_class).find('input[type=checkbox]').eq(0).prop('checked', false);
        });
    });


    //导出excel
    function toExcel() {
        var LongTerm = $("#LongTerm").val();
        var pay_mode = $("#pay_mode").val();
        var reconciliation_state = $("#reconciliation_state").val();
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var pageNum = '${page.currentPage}';
        window.location.href = '<%=basePath%>reconciliation/excel.do?LongTerm=' + LongTerm + '&pay_mode=' + pay_mode + '&startTime=' + startTime +'&endTime=' + endTime + '&pageNum=' + pageNum;
    }
</script>
</html>
